home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -websites- / haage&partner / ftp / classx / fm3-demo.lha / FM3-DEMO / Rexx / AnimText.rexx next >
OS/2 REXX Batch file  |  1997-09-04  |  6KB  |  238 lines

  1. /******************************************************************/
  2. /* ClassX Amiga Rexx script - Copyright © 1997 ClassX Development */
  3. /******************************************************************/
  4.  
  5. /*
  6.     $VER: AnimText.rexx 3.0
  7. */
  8.  
  9. /*
  10. #ITA "Animazione Testo (ANIM5)"
  11. #INF "Crea un testo animato in formato IFF-ANIM5."
  12. #INF "- Descrizione:"
  13. #INF "  La funzione genera un testo animato in formato IFF-ANIM5 agendo"
  14. #INF "  sui settaggi e le tessiture attribuite al font. Almeno una delle"
  15. #INF "  tessiture deve essere composta da più fotogrammi."
  16. #INF "- Uso:"
  17. #INF "  Dopo aver impostato correttamente l'aspetto del font è sufficiente"
  18. #INF "  seguire le istruzioni a video rispondendo alle richieste del"
  19. #INF "  programma."
  20. #END
  21. */
  22.  
  23. /*
  24. #ENG "Anim Text (ANIM5)"
  25. #INF "Create an animated text in IFF-ANIM5 format."
  26. #INF "- Description:"
  27. #INF "  This function generates an animated text in IFF-ANIM5 format,"
  28. #INF "  working with the settings and the textures applied to the font."
  29. #INF "  At least one of the textures must have more than one frame."
  30. #INF "- Usage:"
  31. #INF "  Simply follow the instructions on screen and answer the questions"
  32. #INF "  which will be asked by the program."
  33. #END
  34. */
  35.  
  36.  
  37. MYPORT = 'FontMachine'
  38.  
  39. IF ~SHOW('P', MYPORT) THEN DO
  40.     IF EXISTS('FontMachine:FontMachine') THEN DO
  41.         ADDRESS COMMAND 'Run >NIL: FontMachine:FontMachine'
  42.         DO 30 WHILE ~SHOW('P',MYPORT)
  43.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  44.         END
  45.     END
  46.     ELSE DO
  47.         SAY "FontMachine could not be loaded."
  48.         EXIT 10
  49.     END
  50. END
  51.  
  52. IF ~SHOW('P', MYPORT) THEN DO
  53.     SAY 'FontMachine Rexx port could not be opened.'
  54.     EXIT 10
  55. END
  56.  
  57. ADDRESS VALUE MYPORT
  58. OPTIONS RESULTS
  59. OPTIONS FAILAT 10000
  60.  
  61. /* Make sure rexxsupport library is opened */
  62. IF ~SHOW('L','rexxsupport.library') THEN CALL ADDLIB('rexxsupport.library',0,-30)
  63.  
  64. SIGNAL ON Break_C
  65. SIGNAL ON Break_D
  66.  
  67. /******************************************************************/
  68.  
  69. /* check font */
  70.  
  71. GetPrevWinAddress
  72. if FM_RESULT = 0 then EXIT 0
  73.  
  74. /* local vars//settings */
  75.  
  76. FRAMEPATH = "FontMachine:T/frame"
  77. ANIMPATH  = "FontMachine:AnimText/"
  78.  
  79.  
  80. /* language support */
  81.  
  82. LockGui
  83. GetLocale
  84.  
  85. Select 
  86.     /* italiano */
  87.     when FM_RESULT = "ITA" then do
  88.         TXT_01 = '"Digita il testo da animare"'
  89.         TXT_02 = '"Seleziona la tessitura da animare"'
  90.         TXT_03 = '"Fronte|Bordo|Fronte+Bordo|Cancel"'
  91.         TXT_04 = '"Salva Animazione"'
  92.         TXT_05 = '"Quanti fotogrammi di animazione ?"'
  93.         TXT_10 = '"Fine"'
  94.     end
  95.  
  96.     /* english or default language */
  97.     when FM_RESULT = "ENG" then do
  98.         TXT_01 = '"Type the text to animate"'
  99.         TXT_02 = '"Select the texture to animate"'
  100.         TXT_03 = '"Front|Border|Front+Border|Cancel"'
  101.         TXT_04 = '"Save the Animation"'
  102.         TXT_05 = '"How many frames for the AnimText ?"'
  103.         TXT_10 = '"End"'
  104.     end
  105. end
  106.  
  107.  
  108. /* get texture information */
  109. GetTextureFrames FRONT
  110. fframes = FM_RESULT
  111. GetTextureFrames BORDER
  112. bframes = FM_RESULT
  113.  
  114. if (fframes > 1) | (bframes > 1) then do
  115.  
  116.     /* store environment */
  117.     GetPref AUTODRAW
  118.     pref_autodraw = FM_RESULT
  119.     GetPreviewString
  120.     pref_previewstring = FM_RESULT
  121.  
  122.     /* set new environment */
  123.     SetPref AUTODRAW ON
  124.     SetPreviewString '" "'
  125.     call WaitRender
  126.  
  127.     /* cleanup frame path */
  128.     ADDRESS COMMAND 'Delete >NIL: "'FRAMEPATH'#?"'
  129.  
  130.     AskString '"AnimText"' TXT_01 '"'pref_previewstring'"'
  131.     if FM_RESULT ~= '' then do
  132.         previewstring = FM_RESULT
  133.         SetPreviewString '"'FM_RESULT'"'
  134.         CALL WaitRender
  135.  
  136.         Request '"FontMachine"' TXT_02 TXT_03
  137.         sel = FM_RESULT
  138.     
  139.         Select
  140.             /* Front */
  141.             when sel = 1 then do
  142.                 do f=1 to fframes
  143.                     LoadTextureFrame FRONT f
  144.                     CALL WaitRender
  145.                     SavePreview '"'FRAMEPATH || "." || RIGHT(f, 3, "0")'"'
  146.                     if RC ~= 0 then do
  147.                         Request '"FontMachine"' '"'FM_ERROR'"' '"Ok"'
  148.                         break
  149.                     end
  150.                 end
  151.             end
  152.  
  153.             /* Border */
  154.             when sel = 2 then do
  155.                 do f=1 to bframes
  156.                     LoadTextureFrame BORDER f
  157.                     CALL WaitRender
  158.                     SavePreview '"'FRAMEPATH || "." || RIGHT(f, 3, "0")'"'
  159.                     if RC ~= 0 then do
  160.                         Request '"FontMachine"' '"'FM_ERROR'"' '"Ok"'
  161.                         break
  162.                     end
  163.                 end
  164.             end
  165.  
  166.             /* Front+Border */
  167.             when sel = 3 then do
  168.                 totframes = MAX(fframes,bframes)
  169.                 AskString '"AnimText"' TXT_05  totframes
  170.                 if FM_RESULT ~= 0 then totframes = FM_RESULT
  171.  
  172.                 do f=1 to totframes
  173.                     LoadTextureFrame FRONT f
  174.                     LoadTextureFrame BORDER f
  175.                     CALL WaitRender
  176.                     SavePreview '"'FRAMEPATH || "." || RIGHT(f, 3, "0")'"'
  177.                     if RC ~= 0 then do
  178.                         Request '"FontMachine"' '"'FM_ERROR'"' '"Ok"'
  179.                         break
  180.                     end
  181.                 end
  182.             end
  183.  
  184.             /* cancel -> do nothing */
  185.             otherwise nop
  186.  
  187.         end
  188.  
  189.         if sel ~= 0 then do
  190.             /* convert to animation */
  191.             RequestFile TXT_04 '"'ANIMPATH || previewstring || ".anim"'"' SAVEMODE
  192.             ANIMPATH = FM_RESULT
  193.     
  194.             if ANIMPATH ~= "" then do
  195.                 ADDRESS COMMAND 'FontMachine:c/BuildAnim >NIL: "'FRAMEPATH'.001" "'ANIMPATH'"'
  196.             end
  197.  
  198.             /* cleanup frame path */
  199.             ADDRESS COMMAND 'Delete >NIL: "'FRAMEPATH'#?"'
  200.         end
  201.     end
  202.  
  203.     /* restore environment */
  204.     LoadTextureFrame BORDER 1
  205.     LoadTextureFrame FRONT 1
  206.     SetPref AUTODRAW pref_autodraw
  207.     SetPreviewString '"'pref_previewstring'"'
  208.     CALL WaitRender
  209.  
  210. end
  211.  
  212. /* end */
  213. Request '"FontMachine"' TXT_10 'Ok'
  214. UnLockGui
  215. EXIT
  216.  
  217. /******************************************************************/
  218.  
  219. WaitRender: PROCEDURE
  220.     /* wait the rendering of the font */
  221.     DO FOREVER
  222.         CheckRedraw
  223.         if FM_RESULT ~= 0 then ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  224.         else LEAVE
  225.     END
  226. RETURN
  227.  
  228. /******************************************************************/
  229.  
  230. /* break handlers */
  231. Break_C:
  232. Break_D:
  233.     UnLockGui
  234.     Request '"FontMachine"' '"Procedure Stopped"' 'Ok'
  235. RETURN
  236.  
  237. /******************************************************************/
  238.